package cn.lingyangwl.agile.food.core.controller.app;

import cn.lingyangwl.agile.ram.ActionType;
import cn.lingyangwl.agile.ram.RamResource;
import cn.lingyangwl.agile.food.core.model.rqrs.goods.GoodsListReq;
import cn.lingyangwl.agile.food.core.model.rqrs.goods.GoodsListResp;
import cn.lingyangwl.agile.food.model.rqrs.goods.GoodsResp;
import cn.lingyangwl.agile.food.core.service.GoodsService;
import cn.lingyangwl.framework.core.response.Resp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 门店
 * 
 * @author shenguangyang
 */
@Api(tags = "门店")
@RestController
@RequestMapping("/app/goods")
public class AppGoodsController {
    @Resource
    private GoodsService goodsService;


    @ApiOperation(value = "app-查询商品信息")
    @GetMapping("/list")
    @RamResource(action = "appShop:goods:query", name = "app-查询商品信息", type = ActionType.READ)
    public Resp<List<GoodsListResp>> listGoods(@Validated GoodsListReq req) {
        return Resp.ok(goodsService.listGoods(req));
    }

    @ApiOperation(value = "app-查询商品信息")
    @GetMapping("/get")
    @RamResource(action = "appShop:goods:query", name = "app-查询商品信息", type = ActionType.READ)
    public Resp<GoodsResp> getGoods(@RequestParam("goodsId") Long goodsId) {
        return Resp.ok(goodsService.getGoods(goodsId));
    }
}
